package red.stu.window.editor.code;

import java.awt.Color;
import java.util.HashMap;
import java.util.LinkedList;

import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;

public class DefaultLexicon {
	
	public static final Lexicon JSLexicon;
	
	public static final Color DEFAULT_COLOR_SYSKEY = new Color(127, 0, 85);
	public static final Color DEFAULT_COLOR_NUMBER = new Color(232, 65, 12);
	
	public static final SimpleAttributeSet DEFAULT_STYLE_NUMBER;
	public static final SimpleAttributeSet DEFAULT_STYLE_OTHER;
	
	static {
		
		DEFAULT_STYLE_NUMBER = new SimpleAttributeSet();
		StyleConstants.setForeground(DEFAULT_STYLE_NUMBER, DEFAULT_COLOR_NUMBER);
		
		DEFAULT_STYLE_OTHER = new SimpleAttributeSet();
		StyleConstants.setForeground(DEFAULT_STYLE_NUMBER, Color.BLACK);
		
		HashMap<String, LexiconWord> words;
		LinkedList<String> keyword;
		SimpleAttributeSet attr;
		
		// JSLexicon
		words = new HashMap<String, LexiconWord>();
		// syskey - word
		keyword = stringListAdd("break", "do", "instanceof", "typeof",
				"case", "else", "new", "var", "catch", "finally", "return",
				"void", "continue", "for", "switch", "while", "function",
				"this", "with", "default", "if", "throw", "delete", "in",
				"try", "import", "true", "false");
		// syskey - Style
		attr = new SimpleAttributeSet();
		StyleConstants.setBold(attr, true);
		StyleConstants.setForeground(attr, DEFAULT_COLOR_SYSKEY);
		LexiconWord syskey = new LexiconWord(keyword, attr, true);
		words.put("syskey", syskey);
		JSLexicon = new Lexicon(words);
		int i = 123;
	}
	
	private static LinkedList<String> stringListAdd(String ... strs) {
		LinkedList<String> list = new LinkedList<String>();
		for (String s : strs)
			list.add(s);
		return list;
	}
	
}
